"use strict";(globalThis.webpackChunk_github_ui_github_ui=globalThis.webpackChunk_github_ui_github_ui||[]).push([["packages_ref-selector_RefSelector_tsx"],{13523:(e,t,a)=>{a.d(t,{$r:()=>s,M1:()=>l,li:()=>n,pS:()=>o,wE:()=>c});var r=a(71315);let n="X-Fetch-Nonce",i=new Set;function s(e){i.add(e)}function l(){return i.values().next().value||""}function c(e){let t={};return void 0!==e&&(t["X-Fetch-Nonce-To-Validate"]=e),void 0===e?t[n]=l():i.has(e)?t[n]=e:t[n]=Array.from(i).join(","),t}function o(){let e=r.XC?.head?.querySelector('meta[name="fetch-nonce"]')?.content||"";e&&s(e)}},23470:(e,t,a)=>{a.d(t,{F:()=>c});var r,n=a(74848),i=a(5524),s=a(96540),l=a(51220);function c({items:e,itemHeight:t,style:a,renderItem:r,makeKey:i,ariaControls:c,shouldUseActionList:h=!1,className:u,containerRole:f="none"}){let m=(0,s.useRef)(null),g=(0,l.Te)({count:e.length,getScrollElement:(0,s.useCallback)(()=>m.current,[]),estimateSize:(0,s.useCallback)(()=>t,[t])});return(0,n.jsx)(o,{ref:m,style:a,virtualizer:g,id:c,shouldUseActionList:h,className:u,children:g.getVirtualItems().map((t,a)=>(0,n.jsx)(d,{containerRole:f,virtualRow:t,children:r(e[t.index],a)},i(e[t.index])))})}let o=s.forwardRef(function({children:e,style:t,virtualizer:a,id:r,shouldUseActionList:s,className:l},c){return(0,n.jsx)("div",{ref:c,style:t,id:r,className:l,children:s?(0,n.jsx)(i.l,{id:r,role:"menu",style:{height:a.getTotalSize(),width:"100%",position:"relative"},selectionVariant:"single",children:e}):(0,n.jsx)("ul",{role:"menu",style:{height:a.getTotalSize(),width:"100%",position:"relative"},id:r,children:e})})});function d({children:e,containerRole:t="none",virtualRow:a}){return(0,n.jsx)("li",{role:t,style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},children:e})}try{c.displayName||(c.displayName="FixedSizeVirtualList")}catch{}try{(r=VirtualListContainerInner).displayName||(r.displayName="VirtualListContainerInner")}catch{}try{d.displayName||(d.displayName="ItemContainer")}catch{}},37285:(e,t,a)=>{a.d(t,{Av:()=>l,BM:()=>r,HX:()=>h,M_:()=>u,RD:()=>d,rb:()=>n});let r="GraphQLTraces",n="GraphQLTracingRefresh",i=s()?decodeURIComponent(new URLSearchParams(window.location.search).get("disable_clusters")||"").split(",").filter(e=>""!==e):[];function s(){return"undefined"!=typeof window}function l(e){if(!s()||!c()||!e)return;let t=window;t&&!t[r]&&(t[r]=[]),t&&e.__trace&&(t[r].push(e.__trace),"function"==typeof t[n]&&t[n]())}function c(){if(!s())return!1;let e=window;return"true"===new URLSearchParams(window.location.search).get("_tracing")||e&&void 0!==e[r]}function o(){return i.length>0}function d(e){if(!s()||!c()&&!o())return e;let t=new URL(e,window.location.origin);return c()&&t.searchParams.set("_tracing","true"),o()&&t.searchParams.set("disable_clusters",i.join(",")),t.pathname+t.search}function h(e){return i.indexOf(e)>-1}function u(e){if(!s())return;let t=i.indexOf(e);t>-1?i.splice(t,1):i.push(e);let a=new URLSearchParams(window.location.search);a.set("disable_clusters",i.join(",")),window.location.search=a.toString()}},38077:(e,t,a)=>{a.d(t,{z:()=>i});var r=a(74848);let n={HighlightedText:"HighlightedText-module__HighlightedText--XiJMv"};function i({text:e,search:t,hideOverflow:a=!1,overflowWidth:i=0}){let s=(function(e,t){if(!t)return[e];let a=e.toLowerCase().split(t.toLowerCase());if(a.length<2)return[e];let r=0,n=[];for(let i of a)n.push(e.substring(r,r+i.length)),r+=i.length,n.push(e.substring(r,r+t.length)),r+=t.length;return n})(e,t).map((e,t)=>t%2==1?(0,r.jsx)("strong",{className:"color-fg-default",children:e},t):e),l=i?`${i}px`:void 0;return(0,r.jsx)("div",{style:{maxWidth:l,overflow:a?"hidden":"visible",color:t.length?"fg.muted":"fg.default"},className:n.HighlightedText,children:s})}try{i.displayName||(i.displayName="HighlightedText")}catch{}},41245:(e,t,a)=>{a.d(t,{A:()=>r});let r=(e,t)=>{let a=new URL(e,window.location.origin),r=new URL(t,window.location.origin);return r.href.includes("#")&&a.host===r.host&&a.pathname===r.pathname&&a.search===r.search}},51987:(e,t,a)=>{a.d(t,{jC:()=>c,kt:()=>s,tV:()=>l});var r=a(87057),n=a(69599),i=a(13523);function s(e){let t={"X-Requested-With":"XMLHttpRequest",...(0,i.wE)(e)};return(0,n.G7)("client_version_header")&&(t={...t,[r.S]:(0,r.O)()}),t}function l(e,t){for(let[a,r]of Object.entries(s(t)))e.set(a,r)}function c(e){return{"X-GitHub-App-Type":e}}},66990:(e,t,a)=>{a.d(t,{aH:()=>eh,PI:()=>eo,Qe:()=>ed,JJ:()=>ec});var r=a(74848),n=a(21373),i=a(72511),s=a(10436),l=a(25407),c=a(38621),o=a(81960),d=a(26108),h=a(5524),u=a(99511),f=a(69726),m=a(96540),g=a(71315),y=a(54571),p=a(99906),x=a(40961);let S={DialogFooterButtons:"CheckTagNameDialog-module__DialogFooterButtons--HNAWb"};function b({isOpen:e,onDismiss:t,onConfirm:a}){let[i]=(0,y.I)(()=>document.body,null,[g.XC?.body]);return i?(0,x.createPortal)((0,r.jsxs)(p.A,{isOpen:e,onDismiss:t,children:[(0,r.jsx)(p.A.Header,{children:"Create branch"}),(0,r.jsxs)("div",{className:"p-3",children:[(0,r.jsx)("span",{children:"A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?"}),(0,r.jsxs)("div",{className:S.DialogFooterButtons,children:[(0,r.jsx)(n.Q,{onClick:t,children:"Cancel"}),(0,r.jsx)(n.Q,{variant:"danger",onClick:a,className:"ml-2",children:"Create"})]})]})]}),document.body):null}try{b.displayName||(b.displayName="CheckTagNameDialog")}catch{}var R=a(86877),w=a(15220),C=a(96379),_=a(70170);let v={Dialog:"CreateTagDialog-module__Dialog--a69Xp"};function T({onDismiss:e,onCreate:t,initialTagName:a,tagValidationUrl:n}){let[i,s]=(0,m.useState)(a),l=(0,m.useRef)(!1),c=(0,m.useRef)(null),o=i?.trim(),{state:d,message:h,validateTag:f}=function(e){let[t,a]=(0,m.useState)("empty"),[r,n]=(0,m.useState)(""),i=(0,m.useRef)(""),s=(0,m.useCallback)(async t=>{if(i.current=t,!t){a("empty"),n("Tag cannot be blank");return}a("loading");let r=new URL(e,window.location.origin),s=new URLSearchParams(r.search.slice(1));s.append("tag_name",t),r.search=s.toString();try{let e=await (0,C.DI)(r.toString(),{headers:{Accept:"application/json"}});if(t!==i.current)return;if(!e.ok){a("invalid"),n("Unable to validate tag name. Please try again.");return}let s=(await e.json()).status;a(s||"empty"),n(function(e,t){switch(e){case"branch_exists":case"pending":case"valid":return`${t} will be created on publish`;case"duplicate":return`${t} is used by another release`;case"empty":return"Tag cannot be blank";case"immutable":return`${t} is used by an immutable release and cannot be reused`;case"invalid":return"Contains invalid characters. Use safe special characters ., -, or _ instead";default:return""}}(s||"empty",t))}catch{if(t!==i.current)return;a("invalid"),n("Unable to validate tag name. Please try again.")}},[e]);return{state:t,message:r,validateTag:(0,m.useMemo)(()=>(0,_.s)(s,500),[s])}}(n),g="loading"===d,y="empty"===d&&l.current,p="invalid"===d||"immutable"===d||"duplicate"===d||y,x=!g&&h&&("valid"===d||"pending"===d||"branch_exists"===d||p);(0,m.useEffect)(()=>{a?.trim()&&f(a.trim())},[]);let S=(0,m.useCallback)(e=>{let t=e.target.value;s(t),l.current=!0,f(t.trim())},[f]),b=(0,m.useCallback)(()=>{o&&(t(o),e())},[o,t,e]),T=(0,m.useCallback)(e=>{e.preventDefault(),g||p||b()},[b,g,p]);return(0,r.jsx)(w.l,{onClose:e,title:"Create new tag",width:"medium",className:v.Dialog,initialFocusRef:c,footerButtons:[{buttonType:"default",content:"Cancel",onClick:e},{buttonType:"primary",content:"Create",onClick:b,disabled:g||p,type:"submit"}],children:(0,r.jsx)("form",{onSubmit:T,children:(0,r.jsxs)(R.A,{required:!0,children:[(0,r.jsx)(R.A.Label,{children:"Tag"}),(0,r.jsx)(u.A,{ref:c,value:i,onChange:S,"aria-label":"Tag name",block:!0,loading:g}),x&&(0,r.jsx)(R.A.Validation,{variant:p?"error":"success",children:h}),"branch_exists"===d&&(0,r.jsx)(R.A.Caption,{children:"Creating a tag with the same name as a branch can cause ambiguity when selecting refs"})]})})})}try{T.displayName||(T.displayName="CreateTagDialog")}catch{}async function j(e,t){let a=new FormData;a.set("value",t);let r=await (0,C.DI)(e,{method:"POST",body:a,headers:{Accept:"application/json"}});return!!r.ok&&!!await r.text()}async function N(e,t,a){let r=new FormData;r.set("name",t),r.set("branch",a);let n=await (0,C.DI)(e,{method:"POST",body:r,headers:{Accept:"application/json"}});if(n.ok)return{success:!0,name:(await n.json()).name};try{let{error:e}=await n.json();if(e)return{success:!1,error:e};throw Error("Unknown response from create branch API")}catch{return{success:!1,error:"Something went wrong."}}}var k=a(31604),L=a(11683);let O={RefSelectorOverlayBtn:"RefSelectorAnchoredOverlay-module__RefSelectorOverlayBtn--D34zl",RefSelectorOverlayContainer:"RefSelectorAnchoredOverlay-module__RefSelectorOverlayContainer--mCbv8",RefSelectorOverlayHeader:"RefSelectorAnchoredOverlay-module__RefSelectorOverlayHeader--D4cnZ",RefSelectorBtnTextContainer:"RefSelectorAnchoredOverlay-module__RefSelectorBtnTextContainer--yO402",RefSelectorText:"RefSelectorAnchoredOverlay-module__RefSelectorText--bxVhQ"};var I=a(34164);function A(e){let{ariaDescribedBy:t,ariaLabelledBy:a,ariaLabel:i,hotKey:s,onOpenChange:l,size:o,displayCommitish:d,variant:h,refType:u,children:f,preventClosing:g,inputRef:y,overlayOpen:p,onOverlayChange:x,focusTrapEnabled:S=!0,buttonClassName:b,buttonText:R,persistButtonText:w=!0,buttonPrefix:C,showIcon:_=!0,allowResizing:v,useFocusZone:T,disabled:j,anchoredOverlayProps:N,renderAnchor:A}=e,F=e.idEnding?`-${e.idEnding}`:`-${Date.now()}`,E=(0,m.useRef)(`ref-picker${F}`),D=(0,m.useCallback)(e=>{x(e),l?.(e)},[l,x]),V=(0,m.useMemo)(()=>S?{initialFocusRef:y}:{initialFocusRef:y,disabled:!0},[S,y]);return(0,r.jsx)(k.T,{open:p,overlayProps:{role:"dialog",width:"medium","aria-label":"branch"===u?"Select a branch":"Select a tag"},onOpen:()=>D(!0),onClose:()=>!g&&D(!1),renderAnchor:e=>A?A({...e,"aria-labelledby":a,disabled:j}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Q,{...e,"data-hotkey":s,disabled:j,size:o,variant:h,style:{minWidth:v?0:void 0},trailingVisual:c.TriangleDownIcon,"aria-describedby":t,"aria-labelledby":a,"aria-label":a?void 0:i??`${d} ${u}`,"data-testid":"anchor-button",id:E.current,className:(0,I.$)(b,O.RefSelectorOverlayBtn),children:(0,r.jsxs)("div",{className:O.RefSelectorOverlayContainer,children:[_&&(0,r.jsx)("div",{className:O.RefSelectorOverlayHeader,children:"tag"===u?(0,r.jsx)(c.TagIcon,{size:"small"}):(0,r.jsx)(c.GitBranchIcon,{size:"small"})}),(0,r.jsx)("div",{style:{maxWidth:v?void 0:125},className:(0,I.$)("ref-selector-button-text-container",O.RefSelectorBtnTextContainer),children:(0,r.jsxs)("span",{className:O.RefSelectorText,children:["\xa0",(()=>{let e=d.length>0,t=R&&w?R:e?d:R||"";return C?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"fgColor-muted",children:[C,":"]}),(0,r.jsxs)("span",{children:[" ",t]})]}):t})()]})})]})}),(0,r.jsx)("button",{hidden:!0,"data-testid":"ref-selector-hotkey-button","data-hotkey":s,onClick:()=>D(!0),"data-hotkey-scope":"read-only-cursor-text-area",disabled:j})]}),focusTrapSettings:V,focusZoneSettings:T?{bindKeys:L.z0.ArrowAll|L.z0.Tab}:{disabled:!0},...N,children:(0,r.jsx)("div",{"data-testid":"overlay-content","aria-labelledby":E.current,id:"selectPanel",style:{height:"100%"},children:f})})}try{A.displayName||(A.displayName="RefSelectorAnchoredOverlay")}catch{}var F=a(87448);function E({text:e,onClick:t,href:a,sx:n}){let i=!!a,s=(0,r.jsx)(F.az,{sx:{...n},children:e}),l={sx:{minWidth:0}};return i?(0,r.jsx)(h.l.LinkItem,{role:"link",href:a,onClick:()=>t?.(),...l,children:s}):(0,r.jsx)(h.l.Item,{role:"button",onSelect:()=>t?.(),...l,children:s})}try{E.displayName||(E.displayName="RefSelectorFooter")}catch{}var D=a(23470),V=a(26607),P=a(38077),H=a(96459);let B={ItemIcon:"RefItem-module__ItemIcon--uDlDK"},$=m.memo(function({isCurrent:e,isDefault:t,href:a,gitRef:n,filterText:i,ariaPosInSet:s,ariaSetSize:l,onSelect:c,onClick:o,shouldSetAsDiv:d=!1,isPendingTag:u=!1}){let f=(0,r.jsx)(z,{gitRef:n,isDefault:t,isCurrent:e,filterText:i,isPendingTag:u}),m={"aria-posinset":d?void 0:s,"aria-setsize":d?void 0:l,"aria-checked":e,sx:{minWidth:0},onSelect:()=>{c?.(n),a&&g(a,{reloadDocument:!0})},onClick:()=>{o?.(n),a&&g(a,{reloadDocument:!0})}},g=(0,H.Z)();return d?(0,r.jsxs)(h.l.Item,{role:"menuitemradio",as:"div",...m,children:[f,u&&(0,r.jsx)(h.l.TrailingVisual,{className:"fg-muted mr-1",children:"Created on publish"})]}):(0,r.jsxs)(h.l.Item,{role:"menuitemradio",...m,children:[f,u&&(0,r.jsx)(h.l.TrailingVisual,{className:"fg-muted mr-1",children:"Created on publish"})]})}),z=m.memo(function({isCurrent:e,isDefault:t,gitRef:a,filterText:n,showLeadingVisual:i=!0}){return(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"space-between"},children:[(0,r.jsxs)("div",{style:{display:"flex",minWidth:0,alignItems:"flex-end"},children:[i&&(0,r.jsx)(c.CheckIcon,{"aria-hidden":!0,"data-icon-visibility":e?"visible":"hidden",className:B.ItemIcon}),(0,r.jsx)(P.z,{hideOverflow:!0,search:n,text:a},a)]}),t&&(0,r.jsx)(V.A,{children:"default"})]})});try{$.displayName||($.displayName="RefItem")}catch{}try{z.displayName||(z.displayName="RefItemContent")}catch{}let K={FixedSizeVirtualList:"RefsList-module__FixedSizeVirtualList--sfJlf"};function U(e){return e.refs.length>20?(0,r.jsx)(M,{...e}):(0,r.jsx)(W,{...e})}function W({refs:e,defaultBranch:t,currentCommitish:a,getHref:n,filterText:i,onSelectItem:s,ariaControls:l,pendingTag:c}){return(0,r.jsx)("ul",{style:{maxHeight:330,height:"100%",overflowY:"auto",padding:"var(--base-size-8)"},id:l,children:e.map(l=>(0,r.jsx)($,{href:n?.(l),isCurrent:a===l,isDefault:t===l,filterText:i,gitRef:l,onSelect:s,onClick:s,ariaPosInSet:e.indexOf(l)+1,ariaSetSize:e.length,isPendingTag:c===l},l))})}function M({refs:e,defaultBranch:t,currentCommitish:a,getHref:n,filterText:i,onSelectItem:s,ariaControls:l,pendingTag:c}){return(0,r.jsx)(D.F,{ariaControls:l,items:e,itemHeight:32,style:{maxHeight:330,height:"100%",overflowY:"auto",padding:"var(--base-size-8)"},containerRole:"group",makeKey:e=>e,renderItem:l=>(0,r.jsx)($,{shouldSetAsDiv:!0,href:n?.(l),isCurrent:a===l,isDefault:t===l,filterText:i,gitRef:l,onSelect:s,onClick:s,ariaPosInSet:e.indexOf(l)+1,ariaSetSize:e.length,isPendingTag:c===l},l),className:K.FixedSizeVirtualList})}try{U.displayName||(U.displayName="RefsList")}catch{}try{W.displayName||(W.displayName="FullRefsList")}catch{}try{M.displayName||(M.displayName="VirtualRefsList")}catch{}var X=a(69655);function G(e,t,a,r,n){return new X.d("branch"===r?X._.Branch:X._.Tag,n,(0,l.SHX)({owner:t,repo:a,action:"refs"}),e,`${t}/${a}`)}function Q(e,t){let a=e.fetchFailed?"failed":e.isLoading?"loading":"loaded";return{status:a,refs:e.currentSearchResult,showCreateAction:t&&e.searchTerm.length>0&&!e.exactMatchFound,searchIndex:e}}function Z(e){let t=(0,m.useRef)(void 0);return t.current||(t.current=e()),t}var q=a(4559);let J={RefSelectorContainer:"RefSelectorV1-module__RefSelectorContainer--DFuLg",RefSelectorInnerContainer:"RefSelectorV1-module__RefSelectorInnerContainer--pH_Dn",RefSelectorHeading:"RefSelectorV1-module__RefSelectorHeading--FSd2d",RefSelectorCloseButton:"RefSelectorV1-module__RefSelectorCloseButton--x91Lr",RefTypeTabs:"RefSelectorV1-module__RefTypeTabs--slHyr",RefSelectorFilterContainer:"RefSelectorV1-module__RefSelectorFilterContainer--nzwdI",RefSelectorInput:"RefSelectorV1-module__RefSelectorInput--Myj_6",LoadingContainer:"RefSelectorV1-module__LoadingContainer--B9AR4",ZeroStateText:"RefSelectorV1-module__ZeroStateText--ZRhw5",ViewAllRefsActionLink:"RefSelectorV1-module__ViewAllRefsActionLink--riztS",ViewAllRefsActionText:"RefSelectorV1-module__ViewAllRefsActionText--T80I4",BranchOcticon:"RefSelectorV1-module__BranchOcticon--Fpshx",RefActionText:"RefSelectorV1-module__RefActionText--b19i0",Divider:"RefSelectorV1-module__Divider--fKdqp"};function Y(e){let{ariaDescribedBy:t,ariaLabelledBy:a,ariaLabel:n,cacheKey:i,owner:s,repo:c,canCreate:o,canCreateTag:d=!1,types:h,hotKey:u,onOpenChange:f,size:g,variant:y,getHref:p,onBeforeCreate:x,onRefTypeChanged:S,currentCommitish:R,onCreateError:w,onSelectItem:C,closeOnSelect:_,selectedRefType:v,customFooterItemProps:k,buttonClassName:L,buttonText:O,persistButtonText:I,buttonPrefix:F,showIcon:E,allowResizing:D,idEnding:V,useFocusZone:P,disabled:H,anchoredOverlayProps:B,renderAnchor:$}=e,[z,K]=(0,m.useState)(""),U=(0,m.useRef)(null),W=(0,m.useRef)(null),M="tree"===v?R.slice(0,7):R,[X,q]=(0,m.useState)(!1),[J,Y]=(0,m.useState)(!0),[et,ea]=(0,m.useState)(!1),[er,en]=(0,m.useState)(!1),[ei,es]=(0,m.useState)(null),[el,eo]=(0,m.useState)(("tree"===v?"branch":v)??(h??ec)[0]),ed=function(e,t,a,r,n,i){let[s,l]=(0,m.useState)({status:"uninitialized",refs:[],showCreateAction:!1,searchIndex:null}),c=(0,m.useRef)({render:()=>{l(Q(d.current,i))}}),o=(0,m.useRef)({render:()=>{l(Q(h.current,i))}}),d=Z(()=>G(e,t,a,"branch",c.current)),h=Z(()=>G(e,t,a,"tag",o.current));return(0,m.useEffect)(()=>{let n=`${t}/${a}`;d.current.nameWithOwner!==n&&(d.current=G(e,t,a,"branch",c.current)),h.current.nameWithOwner!==n&&(h.current=G(e,t,a,"tag",o.current)),async function(){let e="branch"===r?d.current:h.current;e.render(),await e.fetchData(),e.search(""),e.render()}()},[e,t,a,r,d,h]),(0,m.useEffect)(()=>{let e="branch"===r?d.current:h.current;e.search(n),e.render()},[n,r,d,h]),s}(i,s,c,el,z,o),eh=(0,l.SHX)({owner:s,repo:c,action:"branches"}),eu=(0,l.FeW)({owner:s,repo:c}),ef=(0,l.BUl)({owner:s,repo:c}),em=(0,m.useCallback)(async()=>{x?.(z);let e=await N(eh,z,R);e.success?p&&(ed.searchIndex?.clearLocalStorage(),window.location.href=p(e.name)):w?.(e.error)},[x,z,eh,R,p,w,ed.searchIndex]),eg=(0,m.useCallback)(async()=>{if(await j(eu,z)){ea(!0),Y(!1);return}ea(!1),Y(!1),em()},[eu,z,em,ea]),ey=(0,m.useCallback)(e=>{eo(e),S?.(e)},[eo,S]);function ep(){q(!1)}let ex=(0,m.useCallback)((e,t)=>{C?.(e,t),ep()},[C]),eS=(0,m.useCallback)(()=>{"tag"===el?(ex(z,"tag"),ep()):eg()},[el,z,ex,eg]),eb=(0,m.useCallback)(e=>{ed.refs.includes(e)||es(e),K(""),ex(e,"tag"),en(!1)},[ex,es,K,ed.refs]),eR=(0,m.useCallback)(()=>{en(!0),ep()},[]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(A,{ariaDescribedBy:t,ariaLabelledBy:a,ariaLabel:n,refType:el,displayCommitish:M,focusTrapEnabled:J,preventClosing:et,size:g,variant:y,onOpenChange:f,hotKey:u,inputRef:U,overlayOpen:X,onOverlayChange:q,buttonClassName:L,buttonText:O,persistButtonText:I,buttonPrefix:F,showIcon:E,allowResizing:D,idEnding:V,useFocusZone:P,disabled:H,anchoredOverlayProps:B,renderAnchor:$,children:(0,r.jsx)(ee,{filterText:z,displayCommitish:M,onFilterChange:K,refType:el,onRefTypeChange:ey,refsState:ed,onCreateError:e.onCreateError,showTagWarningDialog:et,setShowTagWarningDialog:ea,onCreateRef:eS,inputRef:U,createButtonRef:W,onSelectItem:ex,closeOnSelect:_,closeRefSelector:ep,customFooterItemProps:k,...e,selectedRefType:el,onOpenCreateTagDialog:eR,pendingTag:ei,canCreateTag:d})}),et&&(0,r.jsx)(b,{isOpen:et,onDismiss:()=>{ea(!1),W.current?.focus()},onConfirm:em}),er&&(0,r.jsx)(T,{onDismiss:()=>en(!1),onCreate:eb,initialTagName:z,tagValidationUrl:ef})]})}function ee({canCreate:e,currentCommitish:t,displayCommitish:a,defaultBranch:i,filterText:s,getHref:l,hideShowAll:u,onSelectItem:f,closeOnSelect:g,closeRefSelector:y,onFilterChange:p,onRefTypeChange:x,owner:S,selectedRefType:b,refsState:R,refType:w,repo:C,types:_,onCreateRef:v,inputRef:T,createButtonRef:j,customFooterItemProps:N,viewAllJustify:k,actionListHeadingText:L,onOpenCreateTagDialog:O,pendingTag:A,canCreateTag:F}){var D;let{refs:V,showCreateAction:P,status:H}=R,B=(0,m.useMemo)(()=>"tag"===w&&A&&!V.includes(A)?[A,...V]:V,[V,A,w]);return(0,m.useEffect)(()=>{let{single:e,plural:t}={branch:{single:"branch",plural:"branches"},tag:{single:"tag",plural:"tags"}}[w],a=`${B.length} ${1===B.length?e:t} found`,r=setTimeout(()=>{(0,q.i)(a)},1e3);return()=>clearTimeout(r)},[B,w]),(0,r.jsxs)("div",{className:"py-2",style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsxs)("div",{className:J.RefSelectorContainer,children:[(0,r.jsxs)("div",{className:J.RefSelectorInnerContainer,children:[(0,r.jsx)(o.A,{as:"h2",className:J.RefSelectorHeading,children:L??((D=_??ec).includes("branch")&&D.includes("tag")?"Switch branches/tags":D.includes("branch")?"Switch branches":D.includes("tag")?"Switch tags":void 0)}),(0,r.jsx)(d.K,{tooltipDirection:"w","aria-label":"Cancel",variant:"invisible",icon:c.XIcon,onClick:y,className:J.RefSelectorCloseButton})]}),(0,r.jsx)(et,{defaultText:s,refType:w,canCreate:e,onFilterChange:p,ref:T})]}),(0,r.jsxs)("div",{style:{paddingBottom:P&&0===B.length?0:2,flex:1,minHeight:0},children:[(_??ec).length>1&&(0,r.jsx)("div",{className:"px-2 pb-2",children:(0,r.jsx)(ed,{refType:w,onRefTypeChanged:x,className:J.RefTypeTabs})}),"loading"===H||"uninitialized"===H?(0,r.jsx)(er,{refType:w}):"failed"===H?(0,r.jsx)(eh,{refType:w}):0!==B.length||P&&"tag"!==w?(0,r.jsx)(U,{ariaControls:"branch"===w?"branches":"tags",filterText:s,refs:B,defaultBranch:"branch"===w?i:"",currentCommitish:w===b?t:"",getHref:l,onSelectItem:e=>{f?.(e,w),g&&y()},pendingTag:A}):(0,r.jsx)(en,{})]}),(0,r.jsxs)(h.l,{className:"p-0",children:[P&&(0,r.jsxs)(r.Fragment,{children:["branch"===w&&V.length>0&&(0,r.jsx)(h.l.Divider,{className:(0,I.$)("d-block mt-0",J.Divider)}),(0,r.jsx)(es,{displayCommitish:a,newRefName:s,onCreateRef:v,createButtonRef:j,refType:w})]}),(!u||N)&&(0,r.jsx)(h.l.Divider,{className:(0,I.$)(`d-block ${P?"mt-2":"mt-0"}`,J.Divider)}),!u&&(0,r.jsx)(ei,{justify:k,refType:w,owner:S,repo:C,onClick:y}),N&&(0,r.jsx)(E,{...N,onClick:function(){N?.onClick?.(),y()}})]}),"tag"===w&&F&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.l.Divider,{className:(0,I.$)("d-block mt-0",J.Divider)}),(0,r.jsx)("div",{className:"px-2",children:(0,r.jsx)(n.Q,{onClick:O,block:!0,children:"Create new tag"})})]})]})}let et=(0,m.forwardRef)(ea);function ea({refType:e,canCreate:t,onFilterChange:a,defaultText:n},i){return(0,r.jsx)("div",{className:J.RefSelectorFilterContainer,children:(0,r.jsx)(u.A,{"aria-label":"tag"===e?"Filter tags":"Filter branches",leadingVisual:c.SearchIcon,value:n,placeholder:"tag"===e?t?"Search or create a new tag":"Search":t?"Find or create a branch...":"Find a branch...",ref:i,onInput:e=>{let t=e.target;t instanceof HTMLInputElement&&a(t.value)},className:J.RefSelectorInput})})}function er({refType:e}){return(0,r.jsx)("div",{className:J.LoadingContainer,children:(0,r.jsx)(f.A,{size:"medium","aria-label":`Loading ${"branch"===e?"branches":"tags"}...`})})}function en(){return(0,r.jsx)("div",{className:J.ZeroStateText,children:"Nothing to show"})}function ei({refType:e,owner:t,repo:a,onClick:n,justify:i="start"}){let s="branch"===e?"branches":"tags";return(0,r.jsx)(h.l.LinkItem,{role:"link",href:(0,l.SHX)({owner:t,repo:a,action:s}),onClick:n,className:J.ViewAllRefsActionLink,children:(0,r.jsxs)("div",{style:{justifyContent:i},className:J.ViewAllRefsActionText,children:["View all ",s]})})}function es({displayCommitish:e,newRefName:t,onCreateRef:a,createButtonRef:n,refType:i}){return"tag"===i?null:(0,r.jsxs)(h.l.Item,{role:"button",onSelect:a,ref:n,children:[(0,r.jsx)(c.GitBranchIcon,{className:J.BranchOcticon}),(0,r.jsx)("span",{children:"Create branch\xa0"}),(0,r.jsx)("span",{className:J.RefActionText,children:t}),(0,r.jsx)("span",{children:"\xa0from\xa0"}),(0,r.jsx)("span",{className:J.RefActionText,children:e})]})}try{Y.displayName||(Y.displayName="RefSelectorV1")}catch{}try{ee.displayName||(ee.displayName="RefSelectorActionList")}catch{}try{et.displayName||(et.displayName="RefTextFilter")}catch{}try{ea.displayName||(ea.displayName="RefTextFilterWithRef")}catch{}try{er.displayName||(er.displayName="Loading")}catch{}try{en.displayName||(en.displayName="RefsZeroState")}catch{}try{ei.displayName||(ei.displayName="ViewAllRefsAction")}catch{}try{es.displayName||(es.displayName="CreateRefAction")}catch{}let el={RefSelectorTabs:"RefSelector-module__RefSelectorTabs--nkSFr",RefSelectorTabLink:"RefSelector-module__RefSelectorTabLink--WGX7u"},ec=["branch","tag"];function eo(e){return(0,r.jsx)(Y,{...e})}function ed({refType:e,onRefTypeChanged:t,sx:a,className:i}){return(0,r.jsxs)(s.jl,{sx:{...a},"aria-label":"Ref type",className:(0,I.$)(el.RefSelectorTabs,i),children:[(0,r.jsx)(s.jl.Link,{as:n.Q,id:"branch-button","aria-controls":"branches",selected:"branch"===e,onClick:()=>t("branch"),className:el.RefSelectorTabLink,children:"Branches"}),(0,r.jsx)(s.jl.Link,{as:n.Q,id:"tag-button","aria-controls":"tags",selected:"tag"===e,onClick:()=>t("tag"),className:el.RefSelectorTabLink,children:"Tags"})]})}function eh({refType:e}){return(0,r.jsxs)(i.A,{variant:"danger",children:["Could not load ","branch"===e?"branches":"tags"]})}try{eo.displayName||(eo.displayName="RefSelector")}catch{}try{ed.displayName||(ed.displayName="RefTypeTabs")}catch{}try{eh.displayName||(eh.displayName="LoadingFailed")}catch{}},69655:(e,t,a)=>{a.d(t,{_:()=>o,d:()=>SearchIndex});var r=a(50467),n=a(82075),i=a(11083);let{getItem:s,setItem:l,removeItem:c}=(0,n.A)("localStorage",{throwQuotaErrorsOnSet:!0}),o={Branch:"branch",Tag:"tag"};let SearchIndex=class SearchIndex{render(){this.selector.render()}async fetchData(){try{if(!this.isLoading||this.fetchInProgress)return;if(!this.bootstrapFromLocalStorage()){this.fetchInProgress=!0,this.fetchFailed=!1;let e=await fetch(`${this.refEndpoint}?type=${this.refType}`,{headers:{Accept:"application/json"}});await this.processResponse(e)}this.isLoading=!1,this.fetchInProgress=!1,this.render()}catch{this.fetchInProgress=!1,this.fetchFailed=!0}}async processResponse(e){if(this.emitStats(e),!e.ok){this.fetchFailed=!0;return}let t=e.clone(),a=await e.json();this.knownItems=a.refs,this.cacheKey=a.cacheKey,this.flushToLocalStorage(await t.text())}emitStats(e){if(!e.ok)return void(0,i.i)({incrementKey:"REF_SELECTOR_BOOT_FAILED"},!0);switch(e.status){case 200:(0,i.i)({incrementKey:"REF_SELECTOR_BOOTED_FROM_UNCACHED_HTTP"});break;case 304:(0,i.i)({incrementKey:"REF_SELECTOR_BOOTED_FROM_HTTP_CACHE"});break;default:(0,i.i)({incrementKey:"REF_SELECTOR_UNEXPECTED_RESPONSE"})}}search(e){let t;if(this.searchTerm=e,""===e){this.currentSearchResult=this.knownItems;return}let a=[],r=[];for(let n of(this.exactMatchFound=!1,this.knownItems))if(!((t=n.indexOf(e))<0)){if(0===t){e===n?(r.unshift(n),this.exactMatchFound=!0):r.push(n);continue}a.push(n)}this.currentSearchResult=[...r,...a]}bootstrapFromLocalStorage(){let e=s(this.localStorageKey);if(!e)return!1;let t=JSON.parse(e);return t.cacheKey===this.cacheKey&&"refs"in t?(this.knownItems=t.refs,this.isLoading=!1,(0,i.i)({incrementKey:"REF_SELECTOR_BOOTED_FROM_LOCALSTORAGE"}),!0):(c(this.localStorageKey),!1)}async flushToLocalStorage(e){try{l(this.localStorageKey,e)}catch(t){if(t.message.toLowerCase().includes("quota")){this.clearSiblingLocalStorage(),(0,i.i)({incrementKey:"REF_SELECTOR_LOCALSTORAGE_OVERFLOWED"});try{l(this.localStorageKey,e)}catch(e){e.message.toLowerCase().includes("quota")&&(0,i.i)({incrementKey:"REF_SELECTOR_LOCALSTORAGE_GAVE_UP"})}}else throw t}}clearSiblingLocalStorage(){for(let e of Object.keys(localStorage))e.startsWith(SearchIndex.LocalStoragePrefix)&&c(e)}clearLocalStorage(){c(this.localStorageKey)}get localStorageKey(){return`${SearchIndex.LocalStoragePrefix}:${this.nameWithOwner}:${this.refType}`}constructor(e,t,a,n,i){(0,r._)(this,"refType",void 0),(0,r._)(this,"selector",void 0),(0,r._)(this,"knownItems",[]),(0,r._)(this,"currentSearchResult",[]),(0,r._)(this,"exactMatchFound",!1),(0,r._)(this,"searchTerm",""),(0,r._)(this,"refEndpoint",void 0),(0,r._)(this,"cacheKey",void 0),(0,r._)(this,"nameWithOwner",void 0),(0,r._)(this,"isLoading",!0),(0,r._)(this,"fetchInProgress",!1),(0,r._)(this,"fetchFailed",!1),this.refType=e,this.selector=t,this.refEndpoint=a,this.cacheKey=n,this.nameWithOwner=i}};(0,r._)(SearchIndex,"LocalStoragePrefix","ref-selector")},87057:(e,t,a)=>{a.d(t,{O:()=>s,S:()=>i});var r=a(71315);let n=r.cg?.document?.head?.querySelector('meta[name="release"]')?.content||"",i="X-GitHub-Client-Version";function s(){return n}},96379:(e,t,a)=>{a.d(t,{DI:()=>s,QJ:()=>c,Sr:()=>o,lS:()=>l});var r=a(51987),n=a(88057),i=a(37285);async function s(e,t={}){var a=e;if(new URL(a,window.location.origin).origin!==window.location.origin)throw Error("Can not make cross-origin requests from verifiedFetch");let{tracingEnabled:l,fetchPath:c}=function(e){let t=new URL(e,window.location.href),a=new URL(window.location.href,window.location.origin),r=a.searchParams.get("_features");r&&!t.searchParams.has("_features")&&t.searchParams.set("_features",r);let n=a.searchParams.get("_tracing");return n&&!t.searchParams.has("_tracing")&&t.searchParams.set("_tracing",n),{tracingEnabled:!!n,fetchPath:e.startsWith(window.location.origin)?t.href:`${t.pathname}${t.search}`}}(e),o={...t.headers,"GitHub-Verified-Fetch":"true",...(0,r.kt)()},d=await fetch(c,{...t,headers:o}),h=d?.headers?.get("X-Github-Request-Id");if(h&&(0,n.Ex)(h),l&&d){let e=d.clone();try{let t=await e.text(),a=t&&JSON.parse(t);(0,i.Av)(a)}catch{}}return d}function l(e,t){let a={...t?.headers??{},Accept:"application/json","Content-Type":"application/json"},r=t?.body?JSON.stringify(t.body):void 0;return s(e,{...t,body:r,headers:a})}function c(e,t={}){let a={...t.headers,"GitHub-Is-React":"true"};return s(e,{...t,headers:a})}function o(e,t){let a={...t?.headers??{},"GitHub-Is-React":"true"};return l(e,{...t,headers:a})}},96459:(e,t,a)=>{a.d(t,{Z:()=>o,o:()=>d});var r=a(96540),n=a(88934),i=a(41245),s=a(65432),l=a(58578),c=a(24518);let o=()=>{let{routes:e}=r.useContext(c.k),t=(0,n.Zp)();return r.useCallback((c,o={})=>{let d=(0,n.o1)(c).pathname;if(!(0,n.ue)(e,d)||o.reloadDocument){let e="string"==typeof c?c:(0,n.AO)(c);o.preventTurbo?window.location.href=e:(async()=>{let{softNavigate:t}=await Promise.all([a.e("vendors-node_modules_github_turbo_dist_turbo_es2017-esm_js"),a.e("packages_soft-navigate_soft-navigate_ts")]).then(a.bind(a,54563));t(e)})()}else{(0,i.A)(location.href,c.toString())||(0,s.SC)("react");let{preventAutofocus:e,...a}=o;(0,r.startTransition)(()=>{t(c,e?{...a,state:{[l.V]:!0,...a.state}}:a)})}},[t,e])},d=()=>{let[e]=(0,n.ok)(),t=o(),{pathname:a}=(0,n.zy)(),i=r.useCallback((r,i={})=>{t({pathname:a,search:(0,n.PI)("function"==typeof r?r(e):r).toString()},i)},[e,t,a]);return[e,i]}}}]); //# sourceMappingURL=packages_ref-selector_RefSelector_tsx-2d4aea405b67.js.map